public class Demo8 {
    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            for(int i = 0; i < 6; i++){
                System.out.println("hello thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        t.start();
        System.out.println("主线程开始等待");
        try {
            t.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("主线程结束等待");
    }
}
